package com.rem.designPattern.builder建造者;


public class ApiInfo {
    private String title;
    private String version;
    private String description;
    private String license;
    private String licenseUrl;

    public ApiInfo() {
    }

    public ApiInfo(String title, String version, String description, String license, String licenseUrl) {
        this.title = title;
        this.version = version;
        this.description = description;
        this.license = license;
        this.licenseUrl = licenseUrl;
    }

    @Override
    public String toString() {
        return "ApiInfo{" +
                "title='" + title + '\'' +
                ", version='" + version + '\'' +
                ", description='" + description + '\'' +
                ", license='" + license + '\'' +
                ", licenseUrl='" + licenseUrl + '\'' +
                '}';
    }
}

class ApiInfoBuilder {
    private String title;
    private String version;
    private String description;
    private String license;
    private String licenseUrl;

    public ApiInfoBuilder title(String title) {
        this.title = title;
        return this;
    }

    public ApiInfoBuilder version(String version) {
        this.version = version;
        return this;
    }

    public ApiInfoBuilder description(String description) {
        this.description = description;
        return this;
    }

    public ApiInfoBuilder license(String license) {
        this.license = license;
        return this;
    }

    public ApiInfoBuilder licenseUrl(String licenseUrl) {
        this.licenseUrl = licenseUrl;
        return this;
    }

    public ApiInfo build() {
        return new ApiInfo(title, version, description, license, licenseUrl);
    }
}

class Test {
    public static void main(String[] args) {
        ApiInfo apiInfo = new ApiInfoBuilder()
                .title("build")
                .description("建造者")
                .license("dsavfsafcsf2343wrw3asdfscdsf")
                .version("v1.0")
                .build();

        System.out.println(apiInfo);
    }
}